package com.minimalist.common.entity.basic.vo.dept;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.minimalist.common.config.swagger.SchemaEnum;
import com.minimalist.common.entity.basic.enums.StatusEnum;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;

@Schema(name = "部门实体")
public class DeptVO implements Serializable{

    @Serial
    private static final long serialVersionUID = 1L;

    @NotNull(message = "部门ID不能为空", groups = {Update.class})
    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(name = "deptId", description = "部门id", type = "string")
    private Long deptId;

    @NotNull(message = "上级部门ID不能为空", groups = {Add.class, Update.class})
    @Schema(name = "parentDeptId", description = "父部门ID", type = "string")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentDeptId;

    @Schema(name = "ancestors", description = "祖级列表", type = "string")
    private String ancestors;

    @NotBlank(message = "部门名称不能为空", groups = {Add.class, Update.class})
    @Schema(name = "deptName", description = "部门名称", type = "string")
    private String deptName;

    @NotNull(message = "排序值不能为空", groups = {Add.class, Update.class})
    @Schema(name = "deptSort", description = "排序值", type = "integer")
    private Integer deptSort;

    @NotNull(message = "部门负责人不能为空", groups = {Add.class, Update.class})
    @Schema(name = "deptLeader", description = "部门负责人", type = "string")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long deptLeader;

    @NotBlank(message = "部门电话不能为空", groups = {Add.class, Update.class})
    @Schema(name = "phone", description = "部门电话", type = "string")
    private String phone;

    @NotBlank(message = "部门邮箱不能为空", groups = {Add.class, Update.class})
    @Schema(name = "email", description = "部门邮箱", type = "string")
    private String email;

    @SchemaEnum(implementation = StatusEnum.class)
    @NotNull(message = "部门状态不能为空", groups = {Update.class})
    @Schema(name = "status", description = "部门状态", type = "integer")
    private Integer status;

    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(name = "tenantId", description = "租户ID", type = "string")
    private Long tenantId;

    @Schema(name = "children", description = "部门子集", type = "array")
    private List<DeptVO> children;

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public Long getParentDeptId() {
        return parentDeptId;
    }

    public void setParentDeptId(Long parentDeptId) {
        this.parentDeptId = parentDeptId;
    }

    public String getAncestors() {
        return ancestors;
    }

    public void setAncestors(String ancestors) {
        this.ancestors = ancestors;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public Integer getDeptSort() {
        return deptSort;
    }

    public void setDeptSort(Integer deptSort) {
        this.deptSort = deptSort;
    }

    public Long getDeptLeader() {
        return deptLeader;
    }

    public void setDeptLeader(Long deptLeader) {
        this.deptLeader = deptLeader;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Long getTenantId() {
        return tenantId;
    }

    public void setTenantId(Long tenantId) {
        this.tenantId = tenantId;
    }

    public List<DeptVO> getChildren() {
        return children;
    }

    public void setChildren(List<DeptVO> children) {
        this.children = children;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        DeptVO deptVO = (DeptVO) o;
        return java.util.Objects.equals(deptId, deptVO.deptId) &&
               java.util.Objects.equals(parentDeptId, deptVO.parentDeptId) &&
               java.util.Objects.equals(ancestors, deptVO.ancestors) &&
               java.util.Objects.equals(deptName, deptVO.deptName) &&
               java.util.Objects.equals(deptSort, deptVO.deptSort) &&
               java.util.Objects.equals(deptLeader, deptVO.deptLeader) &&
               java.util.Objects.equals(phone, deptVO.phone) &&
               java.util.Objects.equals(email, deptVO.email) &&
               java.util.Objects.equals(status, deptVO.status) &&
               java.util.Objects.equals(tenantId, deptVO.tenantId) &&
               java.util.Objects.equals(children, deptVO.children);
    }

    @Override
    public int hashCode() {
        return java.util.Objects.hash(deptId, parentDeptId, ancestors, deptName, deptSort, deptLeader, phone, email, status, tenantId, children);
    }

    @Override
    public String toString() {
        return "DeptVO{" +
               "deptId=" + deptId +
               ", parentDeptId=" + parentDeptId +
               ", ancestors='" + ancestors + '\'' +
               ", deptName='" + deptName + '\'' +
               ", deptSort=" + deptSort +
               ", deptLeader=" + deptLeader +
               ", phone='" + phone + '\'' +
               ", email='" + email + '\'' +
               ", status=" + status +
               ", tenantId=" + tenantId +
               ", children=" + children +
               '}';
    }

}
